import axios from 'axios'
import { oss_sts_path } from '@/mylibs/define'
export var oss_sts = { AccessKeyId: '', AccessKeySecret: '', SecurityToken: '' }

export async function get_oss_key() {
  let { data: respose } = await axios({
    url: oss_sts_path,
    method: 'post',
    withCredentials: true
  })
  // console.log(respose)
  if (respose.ret != 0) {
    alert('获取oss sts 失败:' + respose.msg)
    return
  }
  let obj = JSON.parse(respose.res)
  // console.log(obj)
  oss_sts.AccessKeyId = obj.Credentials.AccessKeyId
  oss_sts.AccessKeySecret = obj.Credentials.AccessKeySecret
  oss_sts.SecurityToken = obj.Credentials.SecurityToken
}
